<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="f()">停止</button>
</body>
</html>
<script>
    var a= setTimeout(function(){
        console.log(123456789);
    },5000)
    var b=setInterval(function(){
        console.log(123456);
    },2000)
    function f(){
        clearTimeout(a)
        clearInterval(b)
    }
</script>